class Solution
{
public:
    vector<vector<int>> largestLocal(vector<vector<int>> &grid)
    {
        int n = grid.size();
        int returnSize = n - 2;
        vector<vector<int>> result(returnSize, vector<int>(returnSize, 0));
        for (int i = 0; i < returnSize; ++i)
        {
            for (int j = 0; j < returnSize; ++j)
            {
                int max = 0;
                int num = 0;
                for (int x = 0; x < 3; ++x)
                {
                    for (int y = 0; y < 3; ++y)
                    {
                        num = grid[i + x][j + y];
                        if (num > max)
                        {
                            max = num;
                        }
                    }
                }
                result[i][j] = max;
            }
        }
        return result;
    }
};